﻿package src.com.online.rpg.timer 
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	// A simple counting clock and moving sprite
	public class ClockExample extends Sprite
	{
		private var _time:Number;
		
		private var _clockText:TextField;
		private var _object:Sprite;
		
		public function ClockExample() 
		{
			_clockText = new TextField;
			_clockText.autoSize = TextFieldAutoSize.RIGHT;
			_clockText.defaultTextFormat = new TextFormat(null, null, null, null, null, null, null, null, TextFormatAlign.LEFT);
			_clockText.y = 20;
			_clockText.x = 10;
			addChild(_clockText);
			
			_object = new AngryFace();
			_object.x = 200;
			_object.y = 100;
			_object.scaleX = _object.scaleY = .2;
			addChild(_object);
			
			_time = 0;
		}
		
		public function update(dt:Number):void
		{
			_time += dt;
			
			_clockText.text = ( uint(_time*100)/100 ).toString() + " seconds"
			_object.x = Math.sin(_time) * 200 + 200;
		}
		
	}

}